fix: serialize nil query parameters to \N instead of NULL (#1760)#1797
Open
DobryySoul wants to merge 3 commits intoClickHouse:mainfrom
Open
fix: serialize nil query parameters to \N instead of NULL (#1760)#1797DobryySoul wants to merge 3 commits intoClickHouse:mainfrom
DobryySoul wants to merge 3 commits intoClickHouse:mainfrom
Conversation
…#1760) Resolves ClickHouse#1760. When using native query parameters like {param:Nullable(Type)}, ClickHouse expects nil/NULL values to be encoded as '\N' in the tab-separated payload, but the driver previously passed the string literal 'NULL'.
be2dede to
1659fe8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1760.
What changes did you make?
When passing
nilto a query parameter (e.g.{is_etf:Nullable(Bool)}), the driver previously serialized it as the string literal"NULL". Because native Query Parameters in ClickHouse are passed in theTabSeparatedformat over HTTP/TCP, ClickHouse expects\Nfor SQL NULLs instead. Sending"NULL"caused parsing errors likeCannot parse boolean value here: 'NULL'.This PR fixes the formatting inside
bindQueryOrAppendParameters()so that it correctly serializesnilas\Nfor query parameters, while leaving the legacy string replacement behavior intact.Checklist:
niltranslates to\Nand other types remain unaffectedtests&tests/std) to verifyNullableparameters on a real servermake test